<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="pg" uri="http://jsptags.com/tags/navigation/pager" %>
<%--
  Created by IntelliJ IDEA.
  User: 15c
  Date: 2017/5/5
  Time: 10:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<jsp:include page="head.jsp"/>
<br>
<div style="width:100%;height: auto;text-align: center;margin-top: 1%">
    <div>
        <sf:form method="get" action="${pageContext.request.contextPath}/students/retrieval">
            <input type="text" name="keyword"/>
            <input type="submit" value="检索"/>
        </sf:form>
    </div>
<table border="5" cellpadding="4" cellspacing="3" align="center">
    <thead>
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>年龄</th>
        <th>系别</th>
        <th>身份证号</th>
        <th>联系方式</th>
        <th>家庭住址</th>
        <th>执行操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pager.datas}" var="student">
        <tr>
            <td>${student.sno}</td>
            <td>${student.sname}</td>
            <td>${student.ssex} </td>
            <td>${student.sage}</td>
            <td>${student.sdept}</td>
            <td>${student.sid}</td>
            <td>${student.stelephonenum}</td>
            <td>${student.saddress}</td>
            <td>
                <div style="background-color:#aa001b;float: left ;cursor:pointer;text-align: center"><a
                        href="${pageContext.request.contextPath}/students/delete?sno=${student.sno}"
                        style="font-size: 14px;color: #fff">删除</a></div>
                <div style="margin-left: 5px;background-color:#1648aa;float: left ;cursor:pointer;text-align: center"><a
                        href="${pageContext.request.contextPath}/students/update?sno=${student.sno}"
                        style="font-size: 14px;color: #fff">更新</a></div>
                <div style="margin-left: 5px;background-color:#ddb413;float: right ;cursor:pointer;text-align: center"><a
                        href="${pageContext.request.contextPath}/students/view_results?sno=${student.sno}&sname=${student.sname}"
                        style="font-size: 14px;color: #fff">查看成绩</a></div>
            </td>
        </tr>
    </c:forEach>
    </tbody>
    <tr>
        <%--<td colspan="9" align="center">--%>
            <%--<jsp:include page="/WEB-INF/jsp/student/pager.jsp">--%>
                <%--<jsp:param name="url" value="list"/>--%>
                <%--<jsp:param name="items" value="${pager.totalRecord}"/>--%>
                <%--<jsp:param name="totalPage" value="${pager.totalPage}"/>--%>
                <%--<jsp:param name="maxPageItems" value="${pager.pageSize}"/>--%>
            <%--</jsp:include>--%>
        <%--</td>--%>
            <td colspan="9" align="center">
            <pg:pager items="${pager.totalRecord}" maxPageItems="${pager.pageSize}" url="list" maxIndexPages="10" export="curPage=pageNumber">
                共有<span style="color: red">${pager.totalPage}</span>页 当前是第<span style="color: red"><%=curPage%></span>页
                <pg:first>
                    <a href="${pageUrl}">首页</a>
                </pg:first>
                <pg:prev>
                    <a href="${pageUrl}">上一页</a>
                </pg:prev>
                <pg:pages>
                    <c:if test="${curPage eq  pageNumber}">
                        [<span style="color: red;font-weight: bold"><%=pageNumber%></span>]
                    </c:if>
                    <c:if test="${curPage ne pageNumber}">
                        <a href="${pageUrl}">${pageNumber}
                        </a>
                    </c:if>
                </pg:pages>
                <pg:next>
                    <a href="${pageUrl}">下一页</a>
                </pg:next>
                <pg:last>
                    <a href="${pageUrl}">尾页</a>
                </pg:last>
            </pg:pager>
            </td>
    </tr>
</table>
</div>
<script>
//    更新
    var type = "<%=session.getAttribute("type")%>";
    if (type == "ok") {
        (function foo() {
            alert("修改成功");
            <%session.removeAttribute("type");%>
        })
        ();
    } else if (type == "error") {
        (function foo() {
            alert("修改失败");
            <%session.removeAttribute("type");%>
        })
        ();
    }
//    删除
var deletetype="<%=session.getAttribute("delete-type")%>";
if (deletetype == "ok") {
    (function foo() {
        alert("删除成功");
        <%session.removeAttribute("delete-type");%>
    })
    ();
} else if (deletetype == "error") {
    (function foo() {
        alert("删除失败");
        <%session.removeAttribute("delete-type");%>
    })
    ();
}
//     添加
var addtype="<%=session.getAttribute("add-type")%>";
if (addtype == "ok") {
    (function foo() {
        alert("添加成功");
        <%session.removeAttribute("add-type");%>
    })
    ();
} else if (addtype == "error") {
    (function foo() {
        alert("添加失败");
        <%session.removeAttribute("add-type");%>
    })
    ();
}
</script>
</body>
</html>
